/**
 * Created by aa on 2016/7/8.
 */
var Redux=require('redux');
var thunk=require('redux-thunk');
var reducers=require('../reducers');
var createStore=Redux.createStore;
var applyMiddleware=Redux.applyMiddleware;

module.exports = function(initialState) {
    var createStoreWithMiddleware = applyMiddleware(thunk.default)(createStore);
    var store = createStoreWithMiddleware(reducers, initialState);

    if (module.hot) {
        // Enable Webpack hot module replacement for reducers
        module.hot.accept('../reducers', () => {
            const nextReducer = require('../reducers');
            store.replaceReducer(nextReducer)
        })
    }

    return store
};